﻿
/***********************************************/
//当前页面实例
var currentPage;
//控件集合实例
var controlsCollection;
//命名空间
var HelpList;

$(document).ready(function () {
    var collection = [
//            New(ASPxRFTextBox, ['txtTitleText', ['GroupA'], 'Title']),
//            New(ASPxRFTextBox, ['txtNoticeObjectText', ['GroupA'], 'NoticeObject']),
//            New(ASPxRFTextBox, ['txtResponsibilityText', ['GroupA'], 'Responsibility']),
//            New(ASPxRFTextBox, ['txtPublisherText', ['GroupA'], 'Publisher']),
//            New(ASPxRFDateEdit, ['dePublishDate', ['GroupA'], 'PublishDate', 'yyyy-MM-dd HH:mm:ss'])
        ];
    controlsCollection = New(RapidForm, [collection]);

    //页面命名空间简写
    HelpList = SGDemo.Permission.HelpList;

    //声明页面信息
    var navigationInfo = { moduleValue: 'Permission', itemValue: 'HelpItem', itemName: '帮助明细' };
    currentPage = New(RFPage, [menuHeader, gvwList, ['btnView', 'btnEdit'], ['btnDelete'], null, navigationInfo]);
    currentPage.firstLoad();
});

/***********************************************/
//GridView选中全部或者取消选中全部
var doSelectOrUnselectAll = function (s, e) {

    gvwList.SelectAllRowsOnPage(s.GetChecked());
}
//TreeListView选择事件
function doSelectTree(s, e) {
    var keyid = e.nodeKey;
    lblKeyid.SetText(keyid);
}
//GridView双击行打开明细
function doRowDblClick(s, e) {
    currentPage.rowDblClick(s, e);

}
//查看通讯录类别
var doViewContact = function () {

    top.navTab.openTab('Views/Permission/Common/HelpCategoryList.aspx', 'Views/Permission/Common/HelpCategoryList.aspx?',
    { title: '帮助类别管理', fresh: true, external: true, data: {} });
}
//查找提交
function doSubmittedToSearch(s, e) {
    doListAll();
    $('#hfFilterCondition').val(controlsCollection.getQueryString('GroupA'));
    $('#hfFilterDoc').val(keyid);
    gvwList.UnselectAllRowsOnPage();
    gvwList.PerformCallback();
}
//查找重置
var doResetToSearch = function (s, e) {
    controlsCollection.reset('GroupA');
}
//打印
var doPrint = function () {
    window.print();
}
//查找
var doSearch = function () {
    doDisplay('search');
    txtTitleText.Focus();
    currentPage.toSearch();
}
//显示所有
var doListAll = function () {
    doDisplay('listall');
    currentPage.toListAll();
}
//明细
var doView = function () {
    currentPage.toView();
}
//新增
var doAdd = function () {
    tlList.GetNodeValues(tlList.GetFocusedNodeKey(), 'HelpCategoryName', function (result) {
        var autoId = new Date().getTime().toString();
        var tabId = 'Views/Permission/Common/HelpItem.aspx?State=Add&&AutoId=' + autoId;
        var url = 'Views/Permission/Common/HelpItem.aspx?State=Add&ClassKeyid=' + tlList.GetFocusedNodeKey().toString() + '&HelpCategoryName=' + result;
        top.navTab.openTab(tabId, url, { title: '帮助明细', fresh: true, external: true, data: {} });
    });
}
//编辑
var doEdit = function () {
    currentPage.toEdit();
}
//导出数据
var doExport = function () {
    pcExport.Show();
}
//关闭导出数据窗口
var doCloseToExport = function () {
    pcExport.Hide();
}


//GridView选择事件
function doSelectionChanged() {
    currentPage.selectionChanged();
}
//TreeListView选择事件
function doSelectTree(s, e) {
    var keyid = e.nodeKey;
    lblKeyid.SetText(keyid);
}

//双击树节点获得keyid
function doSelectKeyid(s, e) {
    var keyid = e.nodeKey;
    lblKeyid.SetText(keyid);
    var result = "HelpCategoryKeyid=" + keyid;
    $('#hfFilterCondition').val(result);
    gvwList.PerformCallback();

}


//刷新
var doRefresh = function () {
    tlList.PerformCallback();
    gvwList.PerformCallback(lblKeyid.GetText());

}

//删除
var doBulkDelete = function () {
    $.messager.confirm('确认提示', '确认删除吗?', function (result) {
        if (result) {
            //获取选择记录Keyids
            var keyids = gvwList.GetSelectedKeysOnPage().join('_');
            //调用删除方法
            HelpList.BulkDelete(keyids, function (result) {
                if (result.value) {
                    gvwList.PerformCallback(lblKeyid.GetText());
                    $.messager.show({
                        title: '信息提示',
                        msg: '删除成功！',
                        showType: 'slide'
                    });

                } else {
                    $.messager.show({
                        title: '信息提示',
                        msg: '删除失败！',
                        showType: 'slide'
                    });
                }
            });
        }
    });
}

//添加快捷方式
var doSetShortcut = function () {
    SGDemo.Permission.HelpList.SaveFastAdd(function (result) {
        if (result.value) {
            $.messager.show({
                title: '信息提示',
                msg: '添加快捷方式成功！',
                showType: 'slide'
            });

        } else {
            $.messager.show({
                title: '信息提示',
                msg: '添加快捷方式失败！',
                showType: 'slide'
            });
        }

    });
}
//帮助
var doHelp = function () {
    window.open('../../../Help.aspx', 'Help'); // 打开一个标签页
}
